let Jwt = require('./jwt.js').Jwt
//用户相关路由操作
function login(request,response){
    let{query,body}= request
    //判断是否是空对象={}，属性个数为0
    let queryLength = Object.keys(query).length
    if(queryLength){
        let {username} = query
        let jwt = new Jwt(username)
        let token = jwt.generateToken()
        query.token = token
        response.send(query)
    }else{
        let {username} = body
        let jwt = new Jwt(username)
        let token = jwt.generateToken()
        body.token = token
        response.send(body)
    }
}

//请求用户列表的函数
function userList(request,response){
    response.send('userList')
}

exports.login = login
exports.userList = userList